public class HashNode {

    public  class Node{
        public int key;
        public int value;
        public Node next;
        public Node(int key,int value){
            this.key=key;
            this.value=value;
        }

    }
    public Node[] array;
    public HashNode(){
        array=new Node[10];
    }

    public int usedSize;
    public static final double Load_DATA=0.75;

    public void put(int key,int value){
        if(key/array.length>=0.75){


        }

        int index=key%array.length;
        Node cur=array[index];
        while(cur!=null){
            if(cur.key==key){
                cur.value=value;
                return;
            }
            cur=cur.next;
        }
        Node node=new Node(key,value);
        node.next=array[index];
        array[index]=node;
        usedSize++;
    }

    public double calculateLoad(){
        return usedSize*1.0/ array.length;      
    }

    public void resize(){
        Node[] newarray=new Node[array.length*2];
        for (int i = 0; i < array.length; i++) {
            Node cur=array[i];
            while(cur!=null){
                Node curNext=cur.next;
                int index=cur.key%newarray.length;
                cur.next=newarray[index];
                newarray[index]=cur;
                cur=curNext;
            }
        }
        array=newarray;
    }

    public int get(int key){
        int index=key% array.length;
        Node cur=array[index];
        while(cur!=null){
            if(cur.key==key){
                return cur.value;
            }
            cur=cur.next;
        }
        return -1;
    }

}
